home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / hplip / install.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-04-29  |  3.4 KB  |  115 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. __version__ = '1.0'
  5. __title__ = 'HPLIP Installer'
  6. __doc__ = 'Installer for HPLIP tarball.'
  7. import getopt
  8. import os
  9. import os.path as os
  10. import sys
  11. from base.g import *
  12. from base import utils
  13. from installer import core
  14. USAGE = [
  15.     (__doc__, '', 'name', True),
  16.     ('Usage: sh ./hplip-install [MODE] [OPTIONS]', '', 'summary', True),
  17.     utils.USAGE_SPACE,
  18.     ('[MODE]', '', 'header', False),
  19.     ('Run in interactive mode:', '-i or --interactive (Default)', 'option', False),
  20.     utils.USAGE_SPACE,
  21.     utils.USAGE_OPTIONS,
  22.     ('Automatic mode (chooses the most common options):', '-a or --auto', 'option', False),
  23.     utils.USAGE_LOGGING1,
  24.     utils.USAGE_LOGGING2,
  25.     utils.USAGE_LOGGING3,
  26.     utils.USAGE_HELP,
  27.     utils.USAGE_SPACE,
  28.     utils.USAGE_NOTES]
  29.  
  30. def usage(typ = 'text'):
  31.     if typ == 'text':
  32.         utils.log_title(__title__, __version__)
  33.     
  34.     utils.format_text(USAGE, typ, __title__, 'hplip-install', __version__)
  35.     sys.exit(0)
  36.  
  37. log.set_module('hplip-install')
  38. log.debug('euid = %d' % os.geteuid())
  39. mode = INTERACTIVE_MODE
  40. auto = False
  41.  
  42. try:
  43.     (opts, args) = getopt.getopt(sys.argv[1:], 'hl:guiaw', [
  44.         'help',
  45.         'help-rest',
  46.         'help-man',
  47.         'help-desc',
  48.         'logging=',
  49.         'interactive',
  50.         'auto',
  51.         'web',
  52.         'browser'])
  53. except getopt.GetoptError:
  54.     usage()
  55.     sys.exit(1)
  56.  
  57. if os.getenv('HPLIP_DEBUG'):
  58.     log.set_level('debug')
  59.  
  60. for o, a in opts:
  61.     if o in ('-h', '--help'):
  62.         usage()
  63.         continue
  64.     if o == '--help-rest':
  65.         usage('rest')
  66.         continue
  67.     if o == '--help-man':
  68.         usage('man')
  69.         continue
  70.     if o == '--help-desc':
  71.         print __doc__,
  72.         sys.exit(0)
  73.         continue
  74.     if o in ('-l', '--logging'):
  75.         log_level = a.lower().strip()
  76.         if not log.set_level(log_level):
  77.             usage()
  78.         
  79.     log.set_level(log_level)
  80.     if o == '-g':
  81.         log.set_level('debug')
  82.         continue
  83.     if o in ('-i', '--interactive'):
  84.         mode = INTERACTIVE_MODE
  85.         continue
  86.     if o in ('-a', '--auto'):
  87.         auto = True
  88.         continue
  89.     if o in ('-w', '--browser', '--web'):
  90.         mode = BROWSER_MODE
  91.         continue
  92.  
  93. log_file = os.path.normpath('./install.log')
  94. if os.path.exists(log_file):
  95.     os.remove(log_file)
  96.  
  97. log.set_logfile(log_file)
  98. log.set_where(log.LOG_TO_CONSOLE_AND_FILE)
  99. log.debug('Log file=%s' % log_file)
  100. (version_description, version_public, version_internal) = core.getHPLIPVersion()
  101. log.debug('HPLIP Description=%s Public version=%s Internal version = %s' % (version_description, version_public, version_internal))
  102. prop.version = version_public
  103. utils.log_title(__title__, __version__)
  104. if mode == BROWSER_MODE:
  105.     from installer import web_install
  106.     log.debug('Starting web browser installer...')
  107.     web_install.start()
  108. elif mode == INTERACTIVE_MODE:
  109.     from installer import text_install
  110.     log.debug('Starting text installer...')
  111.     text_install.start(auto)
  112. else:
  113.     log.error("Invalid mode. Please use '-i' or '-w' to select the mode.")
  114.     sys.exit(1)
  115.